﻿@model DLULearningNetwork.ViewModels.CourseResourceViewModel
@using DLULearningNetworkModel
@{
    bool isOwner = false;
    if (Course.Single(DLULearningNetwork.Controllers.FrontEndBaseController.LoginUser.AccountID_u, Model.CourseID) != null)
    {
        isOwner = true;
    }
}
<script type="text/javascript">
    $(document).ready(function () {
        CreateCourse.init();
        Resource.init();
    });
</script>
<style type="text/css">
    #ChosenFiles div
    {
        background-color: #dffce2;
        margin-top: 2px;
        padding: 0 3px 0 3px;
        line-height: 27px;
    }
</style>
<div class="loading" id="resourceLoading">
</div>
<div>
@if (ViewBag.CourseResources != null)
{ 
    <div class="box_error" style="display:block;">@ViewBag.CourseResources</div>
}

@using (Html.BeginForm())
{
    if (isOwner)
    {
    <input type="hidden" name="courseID" value="@Model.CourseID" />
    <span id="ChooseExistFiles">Chọn tài nguyên có sẵn: <a class="personal_icon36" href="#">
        Cá nhân</a> <a class="public_icon36" style="padding-left: 44px; margin-left: 10px;"
            href="#">Cộng đồng</a> </span>
    <div class="clearall">
    </div>
    <div id="ChosenFiles" style="width:100%;">
    </div>
    <div class="clearall">
    </div>
    }
    <table class="tbl1" style="width: 100%; margin-top:10px;" cellpadding="0" cellspacing="0">
        <tr>
            <th style="width: 400px; text-align:left;">
                Tên file
            </th>
            <th style="text-align:left;">
                Người đăng
            </th>
            <th style="width:100px;">
            </th>
        </tr>
        @for (int i = 0; i < Model.CoursesFiles.Count; i++)
        {
            DLULearningNetworkModel.File file = DLULearningNetworkModel.File.Single(Model.CoursesFiles[i].FileID_u);
            if (file != null)
            { 
            <tr>
                <td title="@file.FileName_s">
                    @DLULearningNetwork.Libs.StringHelper.ShortcutContent(file.FileName_s, 40)
                </td>
                <td>
                    @DLULearningNetwork.Libs.StringHelper.ShortcutContent(file.Account.Nickname_s, 11)
                </td>
                <td>
                    @Html.ActionLink("Tải về", "Download", new { id = @Model.CourseID , fileID = @file.FileID_u }) 
                    @if (isOwner)
                    {                    
                    <span> | </span><span title="Delete" class="delete_icon16" style="cursor:pointer;"></span>
                    <input type="hidden" name="files" value="@file.FileID_u" />
                    }
                </td>
            </tr>
            }
        }        
    </table>
    if (isOwner)
    {
    <div class="clearall"></div>
    <input style="margin-top:5px; width:70px;" type="button" class="button" value="Lưu" />
    }
}
</div>
